package com.gec.zhs.controller;

import java.util.List;

import com.gec.zhs.entity.query.ApplicationQuery;
import com.gec.zhs.entity.po.Application;
import com.gec.zhs.entity.vo.ResponseVO;
import com.gec.zhs.service.ApplicationService;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * 应用 Controller
 */
@RestController("applicationController")
@RequestMapping("/application")
public class ApplicationController extends ABaseController{

	@Resource
	private ApplicationService applicationService;
	/**
	 * 根据条件分页查询
	 */
	@RequestMapping("/loadDataList")
	public ResponseVO loadDataList(ApplicationQuery query){
		return getSuccessResponseVO(applicationService.findListByPage(query));
	}

	/**
	 * 新增
	 */
	@RequestMapping("/add")
	public ResponseVO add(Application bean) {
		applicationService.add(bean);
		return getSuccessResponseVO(null);
	}

	/**
	 * 批量新增
	 */
	@RequestMapping("/addBatch")
	public ResponseVO addBatch(@RequestBody List<Application> listBean) {
		applicationService.addBatch(listBean);
		return getSuccessResponseVO(null);
	}

	/**
	 * 批量新增/修改
	 */
	@RequestMapping("/addOrUpdateBatch")
	public ResponseVO addOrUpdateBatch(@RequestBody List<Application> listBean) {
		applicationService.addBatch(listBean);
		return getSuccessResponseVO(null);
	}

	/**
	 * 根据Appid查询对象
	 */
	@RequestMapping("/getApplicationByAppid")
	public ResponseVO getApplicationByAppid(String appid) {
		return getSuccessResponseVO(applicationService.getApplicationByAppid(appid));
	}

	/**
	 * 根据Appid修改对象
	 */
	@RequestMapping("/updateApplicationByAppid")
	public ResponseVO updateApplicationByAppid(Application bean,String appid) {
		applicationService.updateApplicationByAppid(bean,appid);
		return getSuccessResponseVO(null);
	}

	/**
	 * 根据Appid删除
	 */
	@RequestMapping("/deleteApplicationByAppid")
	public ResponseVO deleteApplicationByAppid(String appid) {
		applicationService.deleteApplicationByAppid(appid);
		return getSuccessResponseVO(null);
	}
}